package mo.offer_special;

import java.util.ArrayDeque;
import java.util.Queue;

public class L042 {

    private int count = 0;
    private Queue<Integer> queue = new ArrayDeque<>();

    public L042() {

    }

    public int ping(int t) {
        count++;
        int min = t - 3000;
        queue.add(t);
        while (!queue.isEmpty() && queue.peek() < min) {
            queue.poll();
            count--;
        }
        return count;
    }

    public static void main(String[] args) {
        L042 test = new L042();
        System.out.println(test.ping(1));
        System.out.println(test.ping(100));
        System.out.println(test.ping(3001));
        System.out.println(test.ping(3002));
    }

}
